<template>
	<view>
		<view>
			<u-list customStyle = 'height:auto'>
				<u-list-item v-for="(item, index) in enterpriseList" :key="index" @tap=goEditorEnterprise(item.id)>
					<u-cell :title="item.name">
						<u-avatar slot="icon" shape="square" size="35" :src="item.tbPhoto.photoUrl"
							customStyle="margin: -3px 5px -3px 0"></u-avatar>
					</u-cell>
				</u-list-item>
			</u-list>
			<view>
				<u-button type="primary" @click="jump()" icon="plus">新增企业</u-button>
			</view>
		</view>
		<view v-if="enterpriseList.length==0">
			<u-empty ></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		findByUserId
	} from '../../api/enterprise.js'
	export default {
		data() {
			return {
				enterpriseList: []
			}
		},
		methods: {
			findByUserIdFun() {
				let user = uni.getStorageSync("user");
				findByUserId({
					'id': user.id
				}).then(res => {
					console.log(res)
					this.enterpriseList = res.data.data;
				})
			},
			goEditorEnterprise(id) {
				uni.navigateTo({
					url: `/pageB/editorEnterprise/editorEnterprise?id=${id}`
				})
			},
			jump(){
				uni.navigateTo({
					url:'/pageB/addEnterprise/addEnterprise'
				})
			}
		},
		onLoad() {
			this.findByUserIdFun()
		},
		onShow() {
			this.findByUserIdFun()
			
		}
	}
</script>

<style>
	
</style>
